<!--
@ 作者: 阿拉丁矿工 黄传鸿 <hchhyzc@foxmail.com>
-->
<template>
  <div id="PanelCanvas" class="panel_canvas" @contextmenu.prevent="onRightClick" @mousedown="onCanvasMouseDown"
    @mousemove="onCanvasMouseMove" @mouseup="onCanvasMouseUp" @mousewheel="onCanvasWheel"  :style="{
      width: canvasWidth * canvasScale + 'px',
      height: canvasHeight * canvasScale + 'px',
    }">
    <!-- DIV图元 层    -->
    <layer-pel-div></layer-pel-div>
    <!-- SVG图元 层  -->
    <layer-pel-svg></layer-pel-svg>
    <!-- 辅助 层 -->
    <svg class="panel_svg_group" width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink">
      <!-- 绘制显示包 -->
      <g id="DrawShowLayer" :style="{ transform: 'scale(' + canvasScale + ')' }"></g>
      <!-- 选择包 -->
      <LayerSelect></LayerSelect>
      <!-- 光标包 -->
      <layer-cursor></layer-cursor>
      <!-- 编辑包 -->
      <layer-edit></layer-edit>
    </svg>
  </div>
</template>

<script setup lang="ts">
/* ================================================================================================ */
// 🍀引入
/* ================================================================================================ */
import { ref, reactive, onMounted, toRefs, watch, onUnmounted, computed } from "vue";
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// 🐸 引入组件
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
import { LayerPelDiv } from "./component/LayerPelDiv";
import { LayerPelSvg } from "./component/LayerPelSvg";
import { LayerSelect } from "./component/LayerSelect";
import { LayerCursor } from "./component/LayerCursor";
import { LayerEdit } from "./component/LayerEdit";
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// 🐸 图元端函数引入
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
import {
  onCanvasMouseDown,
  onCanvasMouseMove,
  onCanvasMouseUp,
  onCanvasWheel,
  onRightClick,
} from "@/functions";

/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// 🐸 引入存储
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
import { useCanvasStore } from "@/store/canvasStore"; // 画布

/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// 🐸 使用存储
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
const canvasStore = useCanvasStore(); // 画布

/* ================================================================================================ */
//                                 ★ 变量
/* ================================================================================================ */
/** 画布缩放 */
let canvasScale = computed(() => canvasStore.canvasAttr.canvasScale);
/** 画布宽度 */
let canvasWidth = computed(() => canvasStore.canvasAttr.canvasWidth);
/** 画布高度 */
let canvasHeight = computed(() => canvasStore.canvasAttr.canvasHeight);


</script>


<style lang="scss" scoped>
/* 引入共用css */
@import "@/assets/h.scss";

.panel_canvas {
  position: absolute;
  top: 0px;
  left: 0px;
  user-select: none;
  z-index: 100;
}

.panel_svg_group {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 100%;
}

//DIV包
.DIVPel {
  display: block;
}
</style>
